package com.huawei.service.impl;

import com.huawei.dao.PictureMapper;
import com.huawei.dao.SkuMapper;
import com.huawei.dao.SpuMapper;
import com.huawei.entity.Shangpinsku;
import com.huawei.service.SkuService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @ClassName SkuImpl
 * @Description TODO
 * @Author 快乐的大胖
 * @Date 2021/11/30 16:28
 */
@Service
public class SkuImpl implements SkuService {

    @Resource
    SkuMapper skuMappers;

    @Resource
    PictureMapper pictureMapper;
    @Override
    public List<Shangpinsku> selectAll(Map<String, Object> pars) {
        List<Shangpinsku> list =skuMappers.selectAll(pars);

        for (Shangpinsku n:list){
            n.setPicture(pictureMapper.getId(n.getTupian_id()));
        }
        return list;
    }

    @Override
    public int selectCount(Map<String, Object> map) {
        return skuMappers.selectCount(map);
    }


    @Override
    public int insert(Shangpinsku shangpinsku) {

        return skuMappers.insert(shangpinsku);
    }

    @Override
    public int update(Shangpinsku shangpinsku) {

        return skuMappers.update(shangpinsku);
    }

    @Override
    public int delete(int sku_id) {

        return skuMappers.delete(sku_id);
    }

    @Override
    public List<Shangpinsku> getId(int sku_id) {
        return  skuMappers.getId(sku_id);
    }
}
